package com.kevin.minio.config;

import com.kevin.miniospring.EnableMinioOss;
import com.kevin.miniospring.FileUploadTemplate;
import com.kevin.miniospring.PropertiesConfig;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Kevin Liu
 * @date 2020/6/10 8:59 上午
 */
@Configuration
@EnableMinioOss("markdown")
@Data
public class MinioConfig {

    @Bean
    public PropertiesConfig propertiesConfig(){
        return new PropertiesConfig();
    }

    @Bean
    public MinioConfiguration configuration(PropertiesConfig properties)  {
        return new MinioConfiguration(properties.getProperty("clientUrl"), properties.getProperty("username"), properties.getProperty("password"));
    }

    @Bean
    public FileUploadTemplate fileUploadTemplate(MinioConfiguration configuration) {
        FileUploadTemplate fileUploadTemplate = new FileUploadTemplate();
        fileUploadTemplate.setConfiguration(configuration);
        return fileUploadTemplate;
    }
}
